﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{

    public class LogDal
    {
        DBHepler helper = new DBHepler();

        public int WriteLog(Model.Log log)
        {
            SqlParameter[] parameters ={
                                            new SqlParameter("@AppDomainName",log.AppDomainName),
                                            new SqlParameter("@EventID",log.EventID),
                                            new SqlParameter("@FormattedMessage",log.FormattedMessage),
                                            new SqlParameter("@MachineName",log.MachineName),
                                            new SqlParameter("@Message",log.Message),
                                            new SqlParameter("@Priority",log.Priority),
                                            new SqlParameter("@ProcessID",log.ProcessID),
                                            new SqlParameter("@ProcessName",log.ProcessName),
                                            new SqlParameter("@Severity",log.Severity),
                                            new SqlParameter("@ThreadName",log.ThreadName),
                                            new SqlParameter("@Timestamp",log.Timestamp),
                                            new SqlParameter("@Title",log.Title),
                                            new SqlParameter("@Win32ThreadId",log.Win32ThreadId),
                                            new SqlParameter("@LogID",log.LogID)

                                       };
            int logId = helper.InsertByProc("WriteLog", parameters);
            return logId;
        }

        /// <summary>
        /// 获取日志信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetLog()
        {
            return helper.GetDataTableByProc("sp_GetLog");
        }

    }
}
